<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
    <title>上传记录</title>
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css">
    <style type="text/css">
        .layui-table-cell {
            height: 100%;
            max-width: 100%;
        }
    </style>
</head>
<body>

<form class="layui-form">
    <div class="layui-inline">
        <div class="layui-input-inline">
            <input type="text" id="username" style="width: 330px" name="username" lay-verify="required" placeholder="请输入用户账号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <button type="button" class="layui-btn" id="search">搜索</button>
</form>

<table id="fileTable" lay-filter="fileTable"></table>


<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">


    layui.use(['table'],function () {

        var table = layui.table;
        table.render({
            elem:'#fileTable'
            ,url:'cloud-record/list'
            ,where: {
                optionType : 1
            }
            ,page:true
            ,limit:10
            ,limits:[10,20,30,40]
            ,cols:[[
                {field:'id',title:'编号',sort:true,width:80,align:'center'}
                ,{field:'username',title:'账号',align:'center'}
                ,{field:'fileName',title:'文件名称',align:'center'}
                ,{field:'fileImg',title:'封面图片',align:'center',templet:function (d) {
                        return "<img src='"+d.fileImg+"' height='50'/>";
                    }}
                ,{field:'fileType',title:'文件类型',align:'center',templet:function (d) {
                            if (d.fileType == 1) {
                                return "图片";
                            }else if (d.fileType == 2) {
                                return "文档";
                            }else if (d.fileType == 3) {
                                return "音频";
                            }else if (d.fileType == 4) {
                                return "视频";
                            }
                        },width:100}
                ,{field:'fileByte',title:'字节数量',align:'center'}
                ,{field:'fileSize',title:'文件大小',align:'center'}
                ,{field:'fileTime',title:'上传时间',align:'center'}
                ,{field:'fileOperate',title:'操作类型',align:'center',templet:function (d) {
                        if (d.fileOperate == 1) {
                            return "上传";
                        }else if (d.fileOperate == 2) {
                            return "下载";
                        }
                    }, width:100}
            ]]
        });

        /**
         * 搜索功能
         * */
        $("#search").click(function () {
            if($("#username").val() == ""){
                table.reload("fileTable",{
                    url:'cloud-record/list',
                    page:{
                        curr:1
                    },
                    where:{
                        username:null,
                        optionType:1
                    }
                });
            }else{
                table.reload("fileTable",{
                    url:'cloud-record/list',
                    where:{
                        username:$("#username").val(),
                        optionType:1
                    }
                });
            }
        });


    });
</script>
</body>
</html>